class routeService {
    private baseUrl: string;
    private wilddogUrl: string;
    //轨迹定位
    private entityUrl: string;
    private historyUrl: string;

    constructor(private configService:configService) {


        const config = this.configService.getConfig();
         this.baseUrl = "/tms/"; //dev  
        // this.baseUrl = "http://192.168.1.230:5005/tms/"; //李煜
        // this.baseUrl = "http://192.168.1.224:5006/tms/";//孙天宇
        // this.baseUrl = "http://192.168.1.108:5005/tms/";//胡庆伟
        //this.baseUrl = "http://192.168.0.9/api/";
        //this.baseUrl = "http://192.168.0.9/api/";
        //this.wilddogUrl = "https://cjtmsystem-web-dev.wilddogio.com/";
        //this.wilddogUrl = "https://wild-hare-72826.wilddogio.com/";
        
        this.wilddogUrl = config.wilddogUrl;
        
        this.entityUrl = config.entityUrl;
        this.historyUrl = config.historyUrl;
        this.baseUrl = config.baseUrl || "/tms/"; //dev  ;
    }

    getUrl(url: string, value?: any) {
        let result = Mustache.render(this.baseUrl + url, value);
        return result;
    }

    getAttachmentApi(id?) {
        let loginData = JSON.parse(window.localStorage.getItem("loginData"))
        let ulrs = "attachment?id="
        return {
            url:this.baseUrl + ulrs,
            headers:{
                Authorization: "Bearer "+ loginData.jwtToken
            }
        }
    }

    getBaseUrl() {
        return this.baseUrl;
    }

    getWilddogUrl() {
        return this.wilddogUrl;
    }

    getEntityUrl(url: string, value: any) {
        let result = Mustache.render(this.entityUrl + url, value);
        return result;
    }

    
    getHistoryUrl(url: string, value: any) {
        let result = Mustache.render(this.historyUrl + url, value);
        return result;
    }

    print = {
        // reimbursement: "http://tmsystem-front-dev.chinacloudsites.cn/img/reimbursement.jpg",
        // drawMoney: "http://tmsystem-front-dev.chinacloudsites.cn/img/drawMoney.jpg",//dev上的图片
        // url: "http://192.168.0.68:8000/CLodopfuncs.js"
        // url: "https://localhost:8443/CLodopFuncs.js"
        reimbursement: "/src/img/reimbursement.jpg",
        drawMoney: "/src/img/drawMoney.jpg",
        url: "http://192.168.0.68:8000/CLodopfuncs.js?name=CLODOPA"
    };
    Entity = {
        List: "?ak={{ak}}&service_id={{service_id}}&entity_names={{entity_names}}&active_time={{active_time}}&return_type={{return_type}}&page_index={{page_index}}&page_size={{page_size}}",
        History: "?ak={{ak}}&service_id={{service_id}}&start_time={{start_time}}&end_time={{end_time}}&entity_name={{entity_name}}&sort_type={{sort_type}}&simple_return={{simple_return}}&is_processed={{is_processed}}&process_option={{process_option}}&page_index={{page_index}}&page_size={{page_size}}"
    };
    Inquiry = {
        List: 'Inquiry?orderby={{orderby}}&asc={{asc}}&inquiryid={{inquiryid}}&inquirychildid={{inquirychildid}}&clientname={{clientname}}&dispatcherid={{dispatcherid}}&businessaffairsid={{businessaffairsid}}&beginaddress={{beginaddress}}&endaddress={{endaddress}}&states={{states}}&begintime={{begintime}}&endtime={{endtime}}&skip={{skip}}&count={{count}}',
        Delete: "Inquiry/{{id}}",
        Edit: "Inquiry/{{id}}",
        Add: 'Inquiry',
        Detail: 'Inquiry/{{id}}',
        pay: 'inquiry/pay/{{id}}',
        receive: 'inquiry/receive/{{id}}',
        // Export: 'inquiry/export?orderby={{orderby}}&asc={{asc}}&inquiryid={{inquiryid}}&inquirychildid={{inquirychildid}}&clientname={{clientname}}&userid={{userid}}&beginaddress={{beginaddress}}&endaddress={{endaddress}}&state={{state}}&begintime={{begintime}}&endtime={{endtime}}&skip={{skip}}&count={{count}}',
        ExportInquiryList:'inquiry/ExportInquiryList?orderby={{orderby}}&asc={{asc}}&inquiryid={{inquiryid}}&inquirychildid={{inquirychildid}}&clientname={{clientname}}&userid={{userid}}&beginaddress={{beginaddress}}&endaddress={{endaddress}}&state={{state}}&begintime={{begintime}}&endtime={{endtime}}',
        parentId: 'inquiry/parentid',
        client: 'inquiry/client?name={{name}}',
        consignor: 'inquiry/consignor?enterpriseid={{enterpriseid}}&name={{name}}',
        employee: "inquiry/employee?type={{type}}",
        dispatch: "inquiry/dispatch",
        addPay: "inquiry/pay",
        addReceive: "inquiry/receive",
        state: 'inquiry/state'
    };
    Order = {
        exports: 'order/export?orderby={{orderby}}&asc={{asc}}&OrderId={{OrderId}}&ClientName={{ClientName}}&Route={{Route}}&ShipStartTime={{ShipStartTime}}&ShipEndTime={{ShipEndTime}}&Status={{Status}}&PlaceOrderStartTime={{PlaceOrderStartTime}}&PlaceOrderEndTime={{PlaceOrderEndTime}}&ShipAddress={{ShipAddress}}&DeliverAddress={{DeliverAddress}}&CarCode={{CarCode}}&ContractNum={{ContractNum}}&ContractStatus={{ContractStatus}}&ReceiptPriceStatus={{ReceiptPriceStatus}}&OilCardStatus={{OilCardStatus}}&CustomerServiceOfficerId={{CustomerServiceOfficerId}}&DispatchOfficerId={{DispatchOfficerId}}&CarrierName={{CarrierName}}&CarLength={{CarLength}}&OilCardNumber={{OilCardNumber}}&IsOneTier={{IsOneTier}}&driverPhone={{driverPhone}}&ArrivalStartTime={{ArrivalStartTime}}&ArrivalEndTime={{ArrivalEndTime}}',
        receiptexport:'order/receiptexport?orderby={{orderby}}&asc={{asc}}&OrderId={{OrderId}}&ClientName={{ClientName}}&Route={{Route}}&ShipStartTime={{ShipStartTime}}&ShipEndTime={{ShipEndTime}}&Status={{Status}}&PlaceOrderStartTime={{PlaceOrderStartTime}}&PlaceOrderEndTime={{PlaceOrderEndTime}}&ShipAddress={{ShipAddress}}&DeliverAddress={{DeliverAddress}}&CarCode={{CarCode}}&ContractNum={{ContractNum}}&ContractStatus={{ContractStatus}}&ReceiptPriceStatus={{ReceiptPriceStatus}}&OilCardStatus={{OilCardStatus}}&CustomerServiceOfficerId={{CustomerServiceOfficerId}}&DispatchOfficerId={{DispatchOfficerId}}&CarrierName={{CarrierName}}&SettlementStatus={{SettlementStatus}}',
        exports2:'order/export?orderby={{orderby}}&asc={{asc}}&OrderId={{OrderId}}&ClientName={{ClientName}}&Route={{Route}}&ShipStartTime={{ShipStartTime}}&ShipEndTime={{ShipEndTime}}&Status={{Status}}&PlaceOrderStartTime={{PlaceOrderStartTime}}&PlaceOrderEndTime={{PlaceOrderEndTime}}&ShipAddress={{ShipAddress}}&DeliverAddress={{DeliverAddress}}&CarCode={{CarCode}}&ContractNum={{ContractNum}}&ContractStatus={{ContractStatus}}&ReceiptPriceStatus={{ReceiptPriceStatus}}&OilCardStatus={{OilCardStatus}}&CustomerServiceOfficerId={{CustomerServiceOfficerId}}&DispatchOfficerId={{DispatchOfficerId}}&CarrierName={{CarrierName}}&CarLength={{CarLength}}&OilCardNumber={{OilCardNumber}}&IsOneTier={{IsOneTier}}',
        exportOrderList:'order/exportorderlist?orderby={{orderby}}&asc={{asc}}&OrderId={{OrderId}}&ClientName={{ClientName}}&Route={{Route}}&ShipStartTime={{ShipStartTime}}&ShipEndTime={{ShipEndTime}}&Status={{Status}}&PlaceOrderStartTime={{PlaceOrderStartTime}}&PlaceOrderEndTime={{PlaceOrderEndTime}}&DispatchOfficerId={{DispatchOfficerId}}&ShipAddress={{ShipAddress}}&DeliverAddress={{DeliverAddress}}&CustomerServiceId={{CustomerServiceId}}',
        expoetReportCarrierOrderList:'order/ExpoetReportCarrierOrderList?orderby={{orderby}}&asc={{asc}}&ContractNum={{ContractNum}}&ClientName={{ClientName}}&ShipAddress={{ShipAddress}}&DeliverAddress={{DeliverAddress}}&ShipStartTime={{ShipStartTime}}&ShipEndTime={{ShipEndTime}}&CarrierName={{CarrierName}}&Driver={{Driver}}&IsOneTier={{IsOneTier}}'

    };
    fee = {
        exportsFee:'fee/export?orderby={{orderby}}&asc={{asc}}&FeeSettleBillCode={{FeeSettleBillCode}}&FeeCode={{FeeCode}}&ClientName={{ClientName}}&ClientId={{ClientId}}&Applicant={{Applicant}}&ContractNumber={{ContractNumber}}&StartDeliveryTime={{StartDeliveryTime}}&EndDeliveryTime={{EndDeliveryTime}}&StartTime={{StartTime}}&EndTime={{EndTime}}&SettleStartTime={{SettleStartTime}}&SettleEndTime={{SettleEndTime}}&PayStartTime={{PayStartTime}}&PayEndTime={{PayEndTime}}&ContractStatus={{ContractStatus}}&ReceiptStatus={{ReceiptStatus}}&OilCardStatus={{OilCardStatus}}&CarrierId={{CarrierId}}&CarrierName={{CarrierName}}&CarrierPhone={{CarrierPhone}}&CarCode={{CarCode}}&FeeType={{FeeType}}&FeeStatus={{FeeStatus}}&Origin={{Origin}}&Destination={{Destination}}&PaymentMethod={{PaymentMethod}}',

        exportFeePay:'fee/feesettlebillexport?orderby={{orderby}}&asc={{asc}}&FeeSettleBillCode={{FeeSettleBillCode}}&CarrierId={{CarrierId}}&CarrierName={{CarrierName}}&PaymentMethod={{PaymentMethod}}&StartTime={{StartTime}}&EndTime={{EndTime}}&TotalMoney={{TotalMoney}}&ReckonerId={{ReckonerId}}&ContractNumber={{ContractNumber}}&FeeStatusList={{FeeStatusList}}&Origin={{Origin}}&Destination={{Destination}}',
        
        exportDetail:'fee/detailexport?FeeSettleBillCode={{FeeSettleBillCode}}&FeeCode={{FeeCode}}&CarrierName={{CarrierName}}&CarCode={{CarCode}}&ContractNumber={{ContractNumber}}&FeeStatus={{FeeStatus}}',

        exportFinanceFeeList:'fee/ExportFinanceFeeList?orderby={{orderby}}&asc={{asc}}&FeeSettleBillCode={{FeeSettleBillCode}}&FeeCode={{FeeCode}}&ClientName={{ClientName}}&ClientId={{ClientId}}&Applicant={{Applicant}}&ContractNumber={{ContractNumber}}&StartDeliveryTime={{StartDeliveryTime}}&EndDeliveryTime={{EndDeliveryTime}}&StartTime={{StartTime}}&EndTime={{EndTime}}&SettleStartTime={{SettleStartTime}}&SettleEndTime={{SettleEndTime}}&PayStartTime={{PayStartTime}}&PayEndTime={{PayEndTime}}&ContractStatus={{ContractStatus}}&ReceiptStatus={{ReceiptStatus}}&OilCardStatus={{OilCardStatus}}&CarrierId={{CarrierId}}&CarrierName={{CarrierName}}&CarrierPhone={{CarrierPhone}}&CarCode={{CarCode}}&FeeType={{FeeType}}&FeeStatusList={{FeeStatusList}}&Origin={{Origin}}&Destination={{Destination}}&PaymentMethod={{PaymentMethod}}&PayUser={{PayUser}}'
    };
    car = {
        exportsCar:'car/export?orderby={{orderby}}&asc={{asc}}&carcode={{carcode}}&cartype={{cartype}}&carlength={{carlength}}&inputperson={{inputperson}}&driver={{driver}}&driverphone={{driverphone}}&carriercategory={{carriercategory}}&mainroute={{mainroute}}&isenabled={{isenabled}}&startTime={{startTime}}&endTime={{endTime}}&skip={{skip}}&count={{count}}'
    };
    receivable = {
        ExportReceivable:'receivable/ExportReceivable?orderby={{orderby}}&asc={{asc}}&client={{client}}&settle={{settle}}&settleid={{settleid}}&businessaffairsid={{businessaffairsid}}&starttime={{starttime}}&endtime={{endtime}}&carcode={{carcode}}&contractnumber={{contractnumber}}&receiptstatus={{receiptstatus}}&settlestatuslist={{settlestatuslist}}&origin={{origin}}&destination={{destination}}&parentid={{parentid}}&isaccountenroute={{isaccountenroute}}&receivablecodes={{receivablecodes}}&FeeType={{FeeType}}&isArrived={{isArrived}}&receivableSettleBillCode={{receivableSettleBillCode}}&orderStatus={{orderStatus}}&goodsName={{goodsName}}&isindependent={{isindependent}}&realDeliveryStartTime={{realDeliveryStartTime}}&realDeliveryEndTime={{realDeliveryEndTime}}',
        ExportFinance:'receivable/exportstatisticsbill?settle={{settle}}&starttime={{starttime}}&endtime={{endtime}}',
        ExportIncome:'receivable/exportstatisticsincome?settle={{settle}}&starttime={{starttime}}&endtime={{endtime}}',
        ExportAccount:'receivable/exportstatisticsreceivable?settle={{settle}}&starttime={{starttime}}&endtime={{endtime}}&settlestatuslist={{settlestatuslist}}',
        exportReceivable:'receivable/exportstatistics?settle={{settle}}&starttime={{starttime}}&endtime={{endtime}}',
        exportbilllist :'receivable/exportbilllist?orderby={{orderby}}&asc={{asc}}&code={{code}}&reckoner={{reckoner}}&settle={{settle}}&totalmoney={{totalmoney}}&starttime={{starttime}}&endtime={{endtime}}&invoicestarttime={{invoicestarttime}}&invoiceendtime={{invoiceendtime}}&status={{status}}&client={{client}}&settleid={{settleid}}'
    }
    location = {
        Export: 'location/export?StartTime={{StartTime}}&EndTime={{EndTime}}&CarCode={{CarCode}}'
    }
    carrier={
        exportCarrierList:'carrier/export?orderby={{orderby}}&asc={{asc}}&name={{name}}&phone={{phone}}&type={{type}}&inputperson={{inputperson}}&level={{level}}&mainroute={{mainroute}}&isenabled={{isenabled}}&skip={{skip}}&count={{count}}'
    }
    CspInquiry={
        Export:'cspinquiry/export?cspInquiryCode={{cspInquiryCode}}&cspInquiryChildCode={{cspInquiryChildCode}}&clientName={{clientName}}&states={{states}}&beginTime={{beginTime}&endTime={{endTime}}&beginAddress={{beginAddress}}&endAddress={{endAddress}}&skip={{skip}}&count={{count}}',
        List:'CspInquiry?cspInquiryCode={{cspInquiryCode}}&cspInquiryChildCode={{cspInquiryChildCode}}&clientName={{clientName}}&states={{states}}&beginTime={{beginTime}&endTime={{endTime}}&beginAddress={{beginAddress}}&endAddress={{endAddress}}&skip={{skip}}&count={{count}}',
        Detail:'cspinquiry/{{id}}',
        
    }
    CspOrder={
        Export:'csporder/export?orderId={{orderId}}&clientName={{clientName}}&states={{states}}&startTime={{startTime}}&endTime={{endTime}}&startAddress={{startAddress}}&endAddress={{endAddress}}&skip={{skip}}&count={{count}}',
        List:'CspOrder?orderId={{orderId}}&clientName={{clientName}}&states={{states}}&startTime={{startTime}}&endTime={{endTime}}&startAddress={{startAddress}}&endAddress={{endAddress}}&skip={{skip}}&count={{count}}',
        Detail:'csporder/{{id}}',
        
    }
}


angular.module('routeService',[]).service("routeService",["configService",routeService]);